<?php 
define('IN_QY',true);
session_start();
require("include/common.inc.php");
		if($_POST['uid']!=""){	

          $uid = $_POST['uid'];	
		
	}else{		
		$uid = $_COOKIE['userid'];		
	}

$goodid = $_POST['goodid'];
$nums = $_POST['nums'];
$price = $_POST['price'];
$vip_price = $_POST['vip_price'];
$skuid = $_POST['skuid'];

//订单号
$order_id = $uid."a".date('YmdHis',time());

$sql = "select * from tbl_taospp  where id='".$goodid."'";
$query = mysql_query($sql);  
$row=mysql_fetch_array($query);

$totpri = $nums * $price;//总价

		
    //写订单表
    $sql = "insert into tbl_taorder values (0,
	'".$uid."',
	'".$goodid."',
	'".$order_id."',
	'".$price."',
	'".$vip_price."',	
	'".$nums."',
	'".$danx."',
	'".$row['ggnum']."',
	0,
	'".time()."',
	0,
	0,
	0,
	0,
	0,
	'".$totpri."',
	0,
	0,
	0,
	0,
	'".$skuid."',
	0,0,0)";
   $res= mysql_query($sql);
//	
$sqld = "select * from tbl_address where userid='".$uid."' AND moren='1'";
$queryd=mysql_query($sqld);
$rowd=mysql_fetch_array($queryd);

    setcookie("dindanid",$order_id,time()+(3600*8*1*1),"/");   	
	

//改购物车状态

if ($res) {
	$arr = array('error'=>0,'msg'=>'添加成功！');
	echo json_encode($arr);
}